package com.ljfiction.book.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljfiction.book.Baner.FensiRankBean;
import com.ljfiction.book.R;
import com.ljfiction.book.tools.ScreenUtils;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Android on 2017/11/6.
 */

public class FensiRankAdapter extends BaseQuickAdapter<FensiRankBean.DataBean.ListBean, BaseViewHolder> {
    public FensiRankAdapter(@LayoutRes int layoutResId, @Nullable List<FensiRankBean.DataBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FensiRankBean.DataBean.ListBean item) {
        AutoUtils.autoSize(helper.itemView);
        helper.setText(R.id.position_fensirank, String.valueOf(helper.getAdapterPosition()+3))
        .setText(R.id.nameitem_fensirank,item.getUserName())
        .setText(R.id.dengjiitem_fensirank,"LV"+item.getUserGrade())
        .setText(R.id.numitem_fensirank,String.valueOf(item.getFansCount()));
        if (item.getUserSex()==0){
            ((ImageView) helper.getView(R.id.sexitem_fensirank)).setImageResource(R.mipmap.sex_n);
        }else {
            ((ImageView) helper.getView(R.id.sexitem_fensirank)).setImageResource(R.mipmap.sex_v);
        }
        Glide.with(mContext).load(item.getUserHeadPortraitURL()).override(ScreenUtils.getNum(mContext,52),ScreenUtils.getNum(mContext,52)).into((ImageView) helper.getView(R.id.image_fensirankitem));
        helper.addOnClickListener(R.id.image_fensirankitem);
    }
}
